package com.ruoyi.api.rabbitMQ2;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ywh
 * @date 2021/5/26
 * @desc
 */
@Component
public class MessageReceive {

    @RabbitListener(queues = "ueEdu_dead_process_queue")
    public void receive(@Payload String msg, Channel channel, Message message) throws IOException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(new Date()) + ":收到消息:" + msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

}
